//
//  TWWebClient.h
//  TWHomework-WeChat
//
//  Created by wzb on 2019/11/12.
//  Copyright © 2019 WZB. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>

#define  REQUEST_CALLER     @"REQUEST_CALLER"
#define  REQUEST_PAHT       @"REQUEST_PAHT"
#define  REQUEST_MODEL      @"REQUEST_MODEL"

@class TWBaseReponseModel, TWBaseRequestModel;

NS_ASSUME_NONNULL_BEGIN

@interface TWWebClient : AFHTTPSessionManager

/** 存放所有请求 */
@property(nonatomic, strong, readonly) NSArray *httpsArray;

/** 单例方法 */
+ (TWWebClient *)sharedClient;

/** 删除某个请求 */
- (void)removeOperation:(NSURLSessionDataTask *)operation;

/** 删除所有请求 */
- (void)removeAllOperation;

/**
 网络请求基础方法
 
 @param request 参数
 @param success 成功回调
 @param failure 失败回调
 @return 请求
 */
- (NSURLSessionDataTask *)request:(TWBaseRequestModel *)request success:(void (^)(TWBaseReponseModel *response))success failure:(void (^)(NSURLSessionDataTask *operation, NSError *e))failure;

/// 下载图片
/// @param url 图片地址
/// @param success 成功回调
/// @param failure 失败回调
- (void)downloadImage:(NSString *)url success:(void(^)(UIImage *image))success failure:(void(^)(NSError * _Nonnull error))failure;

@end

NS_ASSUME_NONNULL_END
